package com.mgsc.opengllearn.render;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.mgsc.opengllearn.ChooseActivity;
import com.mgsc.opengllearn.R;

public class FGLViewActivity extends AppCompatActivity implements View.OnClickListener{
    private static final int REQ_CHOOSE=0x0101;
    private Button mChange;
    private FGLView mGLView;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_f_g_l_view);
        init();
    }

    private void init(){
        mChange= (Button) findViewById(R.id.mChange);
        mGLView= (FGLView) findViewById(R.id.mGLView);
        mChange.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.mChange) {
            Intent intent = new Intent(this, ChooseActivity.class);
            startActivityForResult(intent, REQ_CHOOSE);
        }
    }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if(resultCode==RESULT_OK){
            mGLView.setShape((Class<? extends Shape>) data.getSerializableExtra("name"));
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        mGLView.onResume();
    }

    @Override
    protected void onPause() {
        super.onPause();
        mGLView.onPause();
    }
}